<template>
	<view>
		<scroll-view scroll-y style='height:100vh;'>
		  
		  <view class='top flex-wrap flex-direction-row'>
			   <image :src="avatar" class='img'></image>
			   <view @click="goLoginPage">
				   <view class='text'>{{isLogin? name :'登录'}}</view>
			   </view>
		  </view>
		  <view class='icon'>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/pending_payment.png' mode="aspectFit"></image>
		      <text>待审批</text>
		    </navigator>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/pending_delivery.png' mode="aspectFit"></image>
		      <text>未审批</text>
		    </navigator>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/already_shipped.png' mode="aspectFit"></image>
		      <text>审批通过</text>
		    </navigator>
		    <navigator url="" hover-class="none" >
		      <image src='../../static/deliver/completed.png' mode="aspectFit"></image>
		      <text>审批失败</text>
		    </navigator>
		  </view>
		  
		  <navigator url="work/work" class='item'>
		    <view class='left'>
		      工作记录
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		  
		  <navigator url="password/change" class='item'>
		    <view class='left'>
		      修改密码
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		
		  <navigator style="display: none;" class='item'>
		    <view class='left'>
		      联系客服
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		
		  <button style="display: none;" class="contact" open-type='contact'/>
		  
		  <navigator @click="logout" url="" class='item'>
		    <view class='left'>
		      退出登录
		    </view>
		    <view class='right'>
		      <image src='../../static/right.png'></image>
		    </view>
		  </navigator>
		  
		  <view style="margin-top:60px;">
		  		  <view class="support"> 毅邦科技提供技术支持</view>
		  		</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLogin: false,
				name: '',
				avatar: '',
			}
		},
		onLoad() {
			var that = this;
			var name = uni.getStorageSync("userid");
			console.log("zzzzzzzzzzzzzzzz")
			uni.login({
			  provider: 'weixin',
			  success: function (loginRes) {
			    console.log(loginRes.authResult);
			    // 获取用户信息
				wx.login({
									success: (res) => {
										console.log(res.code);
									}
								})
				uni.getUserProfile({
					success: async (res) => {
						// 后端接口						
							console.log("9999999999999999");
						},
						fail: (res) => {
							console.log(res)
						}
				});
				
				
			    uni.getUserInfo({
			      provider: 'weixin',
			      success: function (infoRes) {
					that.avatar = infoRes.userInfo.avatarUrl;
					//that.name = infoRes.userInfo.nickName;
			        console.log('用户昵称为：' + infoRes.userInfo.avatarUrl);
			        console.log('用户昵称为：' + infoRes.userInfo.nickName);
			      }
			    });
			  }
			});
			if (name != ""){
				this.isLogin = true
				this.name = name;
				
			}
		},
		methods: {
			goLoginPage(){
				if(!this.isLogin) {
					uni.navigateTo({ url: 'login/login' })
				}
			},
			
			logout(){
				let that = this
				uni.showModal({
				  title: '确定退出登录吗？',
				  success (res) {
				      if (res.confirm) {
							try {
								uni.removeStorageSync('userid')
								uni.removeStorageSync('cookie')
								uni.removeStorageSync('username')
								that.isLogin = false
							} catch (e) {
								that.$uniApi.tipMsg("退出登录失败")
								return
							}	
							that.$uniApi.tipMsg("退出登录成功")
							setTimeout(function(){
								uni.navigateTo({
									url: 'login/login'
								})
							},1500)
				      } 
				    }
				})
			}
		}
	}
</script>

<style>
@import url("my.css");

.logo{
	width: 80rpx;
	height: 80rpx;
	margin-left: 335rpx;
	margin-top: 20px;
	filter: gray;
	-webkit-filter: grayscale(100%);
	  -moz-filter: grayscale(100%);
	  -ms-filter: grayscale(100%);
	  -o-filter: grayscale(100%);
	  filter: grayscale(100%);
}

.support{
	text-align: center;
	width: 100%;
	height: 20px;
	margin-bottom: 10px;
	font-size: 12px;
	color: #888888;
}

</style>
